<?php session_start();
header("Content-type:text/html;charset=utf-8");
if(isset($_POST['submit'])){
	// if(!get_magic_quotes_gpc){
		// foreach($_POST as &$items){
			// $items = addslashes($items);
		// }
	// }
	if($_POST['username'] == 'admin'){
		$_SESSION['login'] = $_POST['username'];//创建全局变量即登录状态为true
		echo "<script>alert('管理员登录成功');location.href='index.php';</script>";
		exit();
	}else{
		echo "<script>alert('登录失败,请检查帐号及密码是否正确');</script>";
	}
}

?>

<form action="#" method="post">
用户名：<input type="text" name="username"><br />
<input type="submit" name="submit" value="登陆" />

</form>